<?php
/**
 * Created by PhpStorm.
 * User: huang
 * Date: 2018/6/25
 * Time: 下午9:19
 */

class Member{

    private $member=array();
    private $tablename='fy_qmy_member';

    #根据数据表,openid,uniacid 初始化

    function __construct($openid,$uniacid)
    {
        global $_W, $_GPC;
        #如果不存在该会员就直接创建
        $member = pdo_get($this->tablename, array('openid' => $openid, 'uniacid' => $uniacid));

        if (empty($member)) {
            $data = array();
            $data['uniacid'] = $uniacid;
            $data['openid'] = $openid;
            $data['uid'] = $_W['member']['uid'];
            $data['createtime']=time();

            if(!empty($openid)){

                pdo_insert($this->tablename, $data);

                $member = pdo_get($this->tablename, array('openid' => $openid, 'uniacid' => $uniacid));

                $this->member=$member;
            }

        } else {

            $this->member = $member;
        }


    }

    public  function getMember(){

        return $this->member;

    }

    public function updateMember($data){

        $member=$this->member;

        pdo_update($this->tablename,$data,array('mid'=>$member['mid']));
    }






}